package gui;

import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.event.FocusEvent;
import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.border.BevelBorder;

public class TDGameFrame extends JFrame implements TDprop{
	TDFrame tdframe;
	
	TDPanelFeld activeGame;
	public TDGameFrame(TDFrame tdf)
	{
		super();
		tdframe = tdf;
		this.setUndecorated(true);	
		this.rootPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		this.rootPane.setLayout(new BorderLayout());
		activeGame = new TDPanelFeld();
		this.rootPane.add(activeGame);
		this.setVisible(true);
		this.enableEvents(AWTEvent.FOCUS_EVENT_MASK);
	}
	
	public void center(Dimension d)
	{
		this.setSize((int)(3*(tdframe.realWidth/4)-tdframe.border), (int) tdframe.realHeight - tdframe.getHeight() - tdframe.border);
		double xp = d.width*(1- tdframe.propx)/2;
		double yp = d.height*(1- tdframe.propy)/2;
	
		this.setLocation((int) xp, (int)yp + tdframe.getHeight() + 5);
		//TODO
	}
	protected void processEvent(AWTEvent e)
	{
		if(e.getID() == FocusEvent.FOCUS_GAINED)
		{
	//		tdframe.showAll();
	//		System.out.println("focus");
		}
		else super.processEvent(e);
	}
}
